#!/bin/sh

PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
distro_name=$(grep "^PRETTY_NAME=" /etc/os-release | sed 's/^PRETTY_NAME=//; s/"//g')

echo;
echo "[ *** ] Welcome to $distro_name!"
echo "Gnu is Not Unix ( G.N.U. ) !!!"
echo "Started GNU/ Xmod Init..."
echo "Mounting everything in /etc/fstab..."
mount -a -O no_netdev

echo "Mounting sys, efi, proc and dev..."
mountpoint -q /sys                 || mount -t sysfs sys /sys -o nosuid,noexec,nodev
mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
[ -d /sys/firmware/efi ] && (mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars)
mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev
mountpoint -q /dev  || mount -t devtmpfs dev /dev -o mode=0755,nosuid

echo "Preparing ttys..."
[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
[ -c /dev/tty1 ]    || mknod -m 620 /dev/tty1 c 4 1
[ -c /dev/tty ]     || mknod -m 666 /dev/tty c 5 0

echo "Creating /dev/null and /dev/kmsg..."
[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11

echo "Making extra symbolic links not provided by default..."
[ -e /dev/fd ]     || ln -snf /proc/self/fd /dev/fd
[ -e /dev/stdin ]  || ln -snf /proc/self/fd/0 /dev/stdin
[ -e /dev/stdout ] || ln -snf /proc/self/fd/1 /dev/stdout
[ -e /dev/stderr ] || ln -snf /proc/self/fd/2 /dev/stderr
[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core

echo "Creating /dev/pts, /dev/shm and /run..."
mkdir -p /dev/pts /dev/shm
mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
mountpoint -q /dev/shm || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
mountpoint -q /run     || mount -t tmpfs run /run -o mode=0755,nosuid,nodev

echo "Enabling swap..."
swapon -a

echo "Setting up hostname..."
[ -s /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"
[ "$HOSTNAME" ] && echo "$HOSTNAME" >| /proc/sys/kernel/hostname

echo;
echo "Starting daemontools-encore..."
lk_prepare /etc/rc
# svc -dx /etc/rc/* /etc/rc/*/log > /dev/null 2>&1
env - PATH=$PATH svscan /etc/rc 2>&1 | \

env - PATH=$PATH readproctitle service errors: ...............................................................................................................................................................................................................................................................................................................................................................................................................
